<template>
  <div class="infinite-container">
    <mu-list class="bgwhite">
      <mu-list-item :title="editFamily.realname">
        <mu-text-field hintTextClass="text-right"  v-model="editFamily.idcard" slot="right" class="mt10" inputClass="text-right" disabled>
        </mu-text-field>
      </mu-list-item>
      <mu-divider></mu-divider>
    </mu-list>

    <div class="content-box mt10">
      <div class="content-title">
        <div>已绑定</div>
      </div>
       <mu-list class="bgwhite">
         <template v-for="(v, i) in editFamily.listHisBusCard" >
          <mu-list-item :title="v.patientBusCardTypeDes + ' - ' + v.patientBusCardNumber" :key="i">
            <mu-raised-button class="small" secondary label="解绑" @click="unbind(v, i)" primary slot="right" />
          </mu-list-item>
          <mu-divider :key="i"></mu-divider>
         </template>
        </mu-list>
    </div>
  
  
    <div class="pd10 t3 f12" style="padding:10px;">
      <div>注意事项：</div>
      <div>1、就诊人绑定医院账号认证后可使用更多系统功能。</div>
      <div>2、就诊人存在多个医院账号时，可通过添加医院其他账户进行绑定。</div>
    </div>

    <div class="addcard-wrapper fixed-bottom">
       <mu-raised-button primary class="submit-btn"  @click="goBindCard" fullWidth>添加医院其他账户</mu-raised-button>
    </div>
      
  </div>
</template>

<script>
import {commonAjax, RESTFUL_API} from '@/api/api'
export default {
  components: {},
  data () {
    return {
      person: JSON.parse(sessionStorage.person || '{}'),
      editFamily: JSON.parse(sessionStorage.editFamily || '{listHisBusCard: []}')
    }
  },
  mounted () {
  },
  methods: {
    unbind (v, i) {
      let query = this.editFamily
      let params = {
        patientCode: v.patientBusCardId,
        uid: query.uid
      }
      if (query.relation > 0) {
        params.fid = query.id
      }
      commonAjax(RESTFUL_API.removeCardByPatientCode, params).then(res => {
        if (res.data.code === 1) {
          this.$store.commit('UPDATE_TOAST', {
            message: '解绑成功'
          })
          this.editFamily.listHisBusCard.splice(i, 1)
        }
      })
    },
    goBindCard () {
      this.$router.push('/setting/bind-visitcard')
    }
  }
}
</script>
<style lang="less" scoped>

</style>
